package cmd

import (
	"fmt"
	"github.com/spf13/cobra"
	"os"
)

var rootCMD = &cobra.Command{
	Use:     "root",
	Short:   "this is a short example",
	Long:    "this is a long example",
	Version: "0.0.1",
	Run:     runHelp,
}

func runHelp(cmd *cobra.Command, args []string) {
	cmd.Help()
}

func init() {
	basicCommonQ := cobra.Group{
		Title: "Basic Commond(Q)",
		ID:    "Q",
	}
	// 将分组添加到root命令
	rootCMD.AddGroup(&basicCommonQ)
	// 将命令添加到分组下
	//rootCMD.AddCommand(get.NewGet(), list.NewList())
	basicCommonCRS := cobra.Group{
		Title: "Basic Command(CRS)",
		ID:    "CRS",
	}
	rootCMD.AddGroup(&basicCommonCRS)
	//rootCMD.AddCommand(create.NewCreate(), delete.NewDelete(), update.NewUpdate())

}

func Execute() {
	if err := rootCMD.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

}
